home *** CD-ROM | disk | FTP | other *** search
/ Power Bytes: Money & Finance / PowerBytes Money and Finance CD-ROM 01 / PowerBytes Money and Finance CD-ROM 01.iso / Demos / TrueBASIC Demo / Read Me < prev   
Encoding:
Text File  |  1986-01-07  |  34.0 KB  |  1,030 lines  |  [TEXT/MACA]

  1.  
  2.                                                 True BASIC, Inc.
  3.                                                 39 South Main Street
  4.                                                 Hanover, N.H.  03755
  5.  
  6.                                                 (603) 643-3882
  7.  
  8.  
  9.                          Demo System
  10.  
  11.  
  12. True BASIC is a new version of BASIC developed by John Kemeny and
  13. Tom Kurtz -- BASIC's original inventors.  It's a modern version
  14. of BASIC which includes control structures, subroutines, and
  15. powerful graphics.  Best of all, True BASIC is based on the proposed
  16. American National Standard for BASIC and is thus the same on
  17. all brands of computers.
  18.  
  19. The True BASIC Demo Disk System is a is a scaled-down, working
  20. copy of the True BASIC Language System.  Your demonstration disk
  21. contains almost exactly the same contents as the full system, except that
  22. the language system has been trimmed back in a few ways.
  23.  
  24. The full True BASIC Language System includes the Language System
  25. software, plus a User's Guide and Reference Manual.  The User's Guide
  26. provides an easy and comprehensive introduction to the language,
  27. and also describes exactly how to use True BASIC on your computer.
  28. The Language System disk contains many small tutorial programs keyed
  29. to the User's Guide.  The Reference Manual is the same for every
  30. computer, and describes the language in detail.
  31.  
  32.  
  33. Demo Disk System Limits
  34.  
  35. The Demo Disk System has a few limits that aren't found in the
  36. full Language System.  Here's a list.
  37.  
  38. o  Program Size
  39.  
  40.       Programs can be up to 100 lines long in the Demo Disk System.
  41.       The full Language System allows any size program that will fit in
  42.       your computer's memory.  (Unlike many other programs, True BASIC
  43.       can use the full memory provided on your computer.)
  44.  
  45.       The Demo Disk System also restricts your program's compiled
  46.       size to no more than 1000 bytes, and allows no more than four
  47.       external subroutines, functions, or pictures.  No such restrictions exist
  48.       in the full Language System.
  49.       
  50. o  Saving and Printing Files
  51.       
  52.       The Demo Disk System does not allow you to save or print files.  The
  53.       full Language System does (of course!).
  54.       
  55. o  File Output
  56.       
  57.       You may open and use files within the Demo Disk System.  However,
  58.       all file output is forbidden.  The full Language System provides
  59.       complete support for text files, random access ``record'' files,
  60.       and low-level ``byte'' files.
  61.       
  62. o  Chaining and Uncompiled Libraries
  63.       
  64.       The Demo Disk System does not let you use True BASIC's CHAIN
  65.       statement, or use source file libraries of subroutines.  The
  66.       full Language System provides a CHAIN command, and lets you
  67.       use compiled or uncompiled libraries as ``toolboxes'' of subroutines
  68.       and functions.
  69.       
  70. o  The DO Command
  71.       
  72.       The Demo Disk System disallows True BASIC's ``DO'' command,
  73.       which lets you run preprocessors, formatters, or pretty-printers
  74.       over your source program.  The full Language System supplies
  75.       several predefined DO programs, and also lets you write your own.
  76.  
  77.  
  78. Ordering the Language System
  79.  
  80. If you want to order a copy of the Language System, contact your
  81. nearest dealer or give us a call.  You'll have your copy within
  82. a day or two.  While you're at it, ask about our special libraries.
  83. Whether you're sorting lists, managing forms on your screen,
  84. or keeping track of data bases, our ``off the shelf'' libraries
  85. can make your job easier.
  86.  
  87.  
  88.  
  89. Getting Started
  90.  
  91. Turn on your Macintosh, and insert your True BASIC ``Demo Disk.''
  92. After a while, your screen should show two open folders.  Double click on
  93. the True BASIC icon, and True BASIC will start running.
  94.  
  95. For practice, try typing in the following simple program.  Remember to press
  96. then Return key at the end of each line.  If you make a typing mistake, use
  97. the Backspace key to erase the mistake.  True BASIC supports all the standard
  98. Macintosh editing techniques.  Thus you can move the insertion point by
  99. clicking with the mouse, highlight words by double clicking, and so forth.
  100.  
  101.         for i = 1 to 10
  102.             print i
  103.         next i
  104.         end
  105.  
  106. Make sure that you've typed everything correctly, and then select Run
  107. from the Run menu.  The screen will go blank, and then your program will
  108. run.  It prints the numbers one through 10.  Since you didn't have an
  109. output window open, True BASIC automatically used the whole screen.
  110. Press any key, or click the mouse, to return to the editing window.
  111.  
  112. You may also run programs by clicking on the bottom ``green'' light in
  113. the traffic light icon, or by holding down the Command key and pressing
  114. R.  Try both.
  115.  
  116. Now let's deliberately introduce a few errors into this program.  Edit
  117. your program so it looks like this:
  118.  
  119.         for i = 1 to
  120.             print i/0
  121.         next n
  122.  
  123. Try running this program.  Since it's full of errors, the True BASIC
  124. compiler points them out.  Notice how it automatically brings the cursor
  125. to the bad spot, and then displays the error message in the ``error bar''
  126. at the bottom of your program window.  Correct the first error, and then
  127. click on the error bar.  Since the compiler found more errors, it will
  128. then bring the cursor to the next error, and print an error message.
  129. Correct it, and click on the error bar again.  Continue this until the
  130. error bar goes blank.
  131.  
  132. Then select Run again.  This time the compiler does not object, since
  133. you've fixed all the obvious errors.  The screen goes blank, but then
  134. immediately reverts to the program window.  Dividing by zero is a
  135. runtime error.  Again, True BASIC shows a message in the error bar,
  136. and brings the cursor to the bad line.
  137.  
  138.      The Output and Command Windows
  139.  
  140. Click on the Output window icon in the control box.  True BASIC opens
  141. an output window.  Now remove the division by zero from your program,
  142. and run it again.  All output appears
  143. in the little output window.  Try using the Output window's scroll bars
  144. to look backward through the output.  Notice that True BASIC keeps
  145. a little bit of history.
  146.  
  147. Now click on the Command window icon.  True BASIC opens a window
  148. in which you can type commands.  Try running your program by typing
  149. ``run'' and pressing Return.  Some people prefer typing commands, and
  150. some prefer using the mouse and menu.  True BASIC accepts both.
  151. True BASIC commands are the same on every computer.  Try scrolling
  152. back through the command window, and you'll see that True BASIC keeps
  153. some history of which commands you've given, and which error messages
  154. you're received.
  155.  
  156. You can tidy up the screen by ``tiling'' all three windows.  Hold down
  157. the Command key and resize the editing window (by dragging its size
  158. box).  The other two windows will shift to make best use of the screen.
  159. You might as well close the Command window now, to avoid cluttering
  160. the screen.
  161.  
  162.      Horizontal Scrolling
  163.  
  164. Resize the editing window to make it very narrow, so some lines are
  165. wider than the window.  Notice that the window does not have horizontal
  166. scroll bars.  This is because BASIC programs are different than English
  167. text.  It makes sense to scroll an entire paragraph sideways, but
  168. it doesn't make sense to scroll a whole True BASIC program.
  169. Each line stands on its own. 
  170.  
  171. To scroll an individual line, move the mouse to the left (or right)
  172. edge of the line, and drag from the text out beyond the edge of the
  173. window.  The line will start scrolling sideways.  When you get to
  174. where you want, let the mouse button up.  Then click somewhere in
  175. the line to turn off the highlighting.  To put a line back to
  176. normal, just click anywhere in another line.
  177.  
  178.  
  179.  
  180. Advanced Editing
  181.  
  182. Call up the program Lissa Box from your disk.  (Select the Open menu
  183. item from the Files menu, and then pick Lissa Box from the list of
  184. filenames shown.)  Make sure you have a small Output window, and
  185. then run the program.
  186.  
  187. Lissa Box doesn't stop until you tell it to.  To stop a True BASIC
  188. program, select Stop from the Run menu.  If the stoplight is visible,
  189. you can also stop programs by clicking on the red light.  Or you
  190. can use the yellow light to ``freeze'' the screen; True BASIC will
  191. wait until you click the green light, or press any key, and then
  192. will continue.
  193.  
  194.      Immediate Mode
  195.  
  196. When you've stopped Lissa Box, open the Command window.  Type the
  197. command ``print x'' and press Return.  True BASIC will show you the
  198. current value of x.  You can use most True BASIC statements as
  199. commands; this lets you inspect and alter variable values.  Type
  200. ``continue'' and press Return to resume the program.  Or click on
  201. the yellow light and then the green light.
  202.  
  203.      Cut, Copy, and Paste
  204.  
  205. The Edit menu contains the Macintosh standard Cut, Copy, and Paste
  206. menu items.  They work as you would expect.  True BASIC uses the
  207. Macintosh clipboard for its cutting and pasting, so you can exchange
  208. text with other applications through the clipboard.
  209.  
  210.      Editing Individual Routines
  211.  
  212. Lissa Box contains a subroutined named Reset.  You can narrow the focus
  213. of your editing to a single subroutine by using the Edit menu item
  214. from the Edit menu.  Select Edit.  True BASIC will present a dialog
  215. box asking the name of the block to edit.  You may type either a
  216. range of line numbers, or the name of a subroutine.  Type ``Reset''
  217. and press Return.  True BASIC will then restrict editing to this
  218. subroutine.
  219.  
  220. Try using the scroll bars.  You can't move out of the Reset subroutine.
  221. Now use the Change menu item (from Search) to change all occurences
  222. of LET to XXX.  Select Change.  When the dialog box appears, type
  223. LET, press the Tab key, and then type XXX.  Then click on the OK
  224. button.  True BASIC will make the changes.  Since you've decided to
  225. edit only the Reset subroutine, True BASIC will make changes only within
  226. this routine.
  227.  
  228. To see the whole program again, select Edit and simply click on OK
  229. without typing anything.  True BASIC will go back to editing your entire
  230. program.
  231.  
  232.      Include and Keep
  233.  
  234. The Include menu item, in the Edit menu, copies a saved file into your
  235. current program.  Select Include.  You will be shown a list of filenames.
  236. Pick ``Cars.''  It will be inserted into your current program, starting at
  237. the line immediately after the line containing the insertion point.
  238.  
  239. The Keep menu item throws away all but some block of lines.  Select
  240. Keep from the Edit menu, and reply Reset to its dialog box.  Click on OK.
  241. True BASIC will discard all but that subroutine.  You can also select
  242. a block of lines by dragging the mouse across it, and then use Keep
  243. to keep only that block of lines.  Give it a try.  True BASIC will
  244. ask to make sure you want to keep only those lines.
  245.  
  246.      Fonts
  247.  
  248. Each True BASIC window has its own font size.  Click on a window, and
  249. then select a font size from the Fonts menu.  True BASIC will change
  250. the size of type used within that window.  Big type is good for
  251. classroom demonstrations, small type fits more of a program on the
  252. screen.  Medium is probably the most comfortable.
  253.  
  254.  
  255.  
  256. True BASIC vs. older BASICs
  257.  
  258. John Kemeny and Tom Kurtz invented BASIC in 1964.  That's the
  259. BASIC used on most microcomputers.  Now they've teamed
  260. up again to reinvent a BASIC for the 1980s -- True BASIC.  As you would
  261. expect, it keeps what's good from older BASICs.  But it also adds
  262. many new features.
  263.  
  264.      All Your Old Favorites
  265.  
  266. True BASIC keeps all the comforts of older BASICs.  The LET, PRINT,
  267. INPUT, READ, DATA statements, and so forth, all work as you would
  268. expect.  As in older BASICs, two types of variables exist: numbers
  269. and strings.  You don't have to learn a new language to start
  270. programming in True BASIC.
  271.  
  272. Only one thing might come as a surprise: the LET keyword is
  273. required in True BASIC, in order to keep the number of reserved
  274. words manageably small.
  275.  
  276.      Line Numbers
  277.  
  278. True BASIC's complete set of modern control structures make line
  279. numbers unnecessary.  Therefore you can write True BASIC programs
  280. without any line numbers.  However, you can still use line numbers
  281. if you wish.
  282.  
  283. If one line has a line number, then all lines must be numbered.
  284. The range of legal numbers is from 1 to 99999.
  285.  
  286.      Numbers and Strings
  287.  
  288. Expressions are computed to at least 10 digits of accuracy on all
  289. computers.  Most computers, such as the IBM PC and the Apple Macintosh,
  290. provide more accuracy -- about 14 digits worth.  If you run True BASIC
  291. on an IBM PC equipped with an 8087 floating point processor, True BASIC
  292. will automatically use the 8087 for arithmetic (and give 16 digits of
  293. accuracy for all expressions).
  294.  
  295. True BASIC strings can be up to 32,000 characters long on all computers.
  296. Some computers support longer strings; for example, the Apple Macintosh
  297. version of True BASIC allows strings up to 1 megabyte long.
  298.  
  299. Arrays may have any number of elements.  The only restriction is that
  300. the entire array must fit in memory.  You must use a DIM statement
  301. for every array, and the DIM statement must appear somewhere before
  302. the array's first use.
  303.  
  304. Many programs use integers for fast computations.  Unlike older
  305. BASICs, True BASIC can automatically determine which variables contain
  306. integer values, and runs faster in those cases.  Yet you never need
  307. to explicitly say which variables are integers!  In fact, True BASIC
  308. doesn't let you add a ``%'' to variable names.  Just sit back and
  309. let the language do the optimizations for you.
  310.  
  311.      Expressions and Substrings
  312.  
  313. True BASIC uses the common +, -, *, /, and ^ marks for arithmetic.
  314. For string concatenation and substrings, it follows the Standard
  315. language.  Thus ``&'' (rather than ``+'') stands for string concatenation.
  316.  
  317. Substrings are indicated by a$[s:e] where s stands for the starting
  318. position in the string, and e stands for the ending position.  You
  319. can use any expression to stand for s and e.  If s < 1, then 1 is
  320. used instead.  If e points past the end of the string, then the
  321. end of the string is used instead.  If s>e, then the substring
  322. is a null string.  You can also assign to substrings; the new
  323. text replaces the old substring, and the full string grows or
  324. shrinks as needed.
  325.  
  326.      Comments and Multiple Statements per Line
  327.  
  328. True BASIC allows the REM statement for comments.  It also lets you
  329. add comments to individual lines.  Anything from an exclamation mark ``!''
  330. to the end of the line is treated as a comment.
  331.  
  332. True BASIC does not allow multiple statements on a line.  The next
  333. page shows how you can use True BASIC's control structures to
  334. created IF-THEN statements containing multiple statements.
  335.  
  336.  
  337.  
  338. Structures
  339.  
  340. In addition to the older GOTO and GOSUB statements, True BASIC also
  341. offers real structures.  ``Spaghetti code'' is no longer the only
  342. game in town.  Clean, modern control structures let you do it
  343. right.
  344.  
  345.      Loops
  346.  
  347. True BASIC has FOR-NEXT loops like older BASICs, but it also introduces
  348. new ``do while'' and ``do until'' loops.  These loops repeat until
  349. some condition becomes true.  You can test the condition at the
  350. start of the loop, or at the end of the loop -- or both.  Or you can
  351. make tests in the middle of a loop, and skip out. 
  352.  
  353. The general forms of the DO loop are:
  354.  
  355.         DO WHILE test           DO UNTIL test
  356.            ...                     ...
  357.         LOOP                    LOOP
  358.  
  359.  
  360.         DO                      DO
  361.            ...                     ...
  362.         LOOP WHILE test         LOOP UNTIL test
  363.  
  364. where the test can be a relational expression such as ``a<b'' or
  365. a more complicated logical expression such as ``a<b or (a=1 and b<10)''.
  366. Loops can have tests on either end, or both.  A WHILE condition
  367. keeps looping while the test is true, and an UNTIL condition keeps
  368. looping until it's true.
  369.  
  370. You may add EXIT DO statements anywhere inside a DO loop.  When
  371. True BASIC executes an EXIT DO statement, it immediately jumps out
  372. of the loop, and begins executing the first statement after the
  373. LOOP statement.
  374.  
  375.      IF-THEN Structures
  376.  
  377. The simplest form of IF statement makes a test, and executes some
  378. statement if the test proves true.  A slightly longer form adds
  379. an ELSE clause, which is executed if the test proves false.  These
  380. statements are written as:
  381.  
  382.         IF test THEN statement
  383.         IF test THEN statement ELSE statement
  384.  
  385. Longer forms let you put multiple statements in the THEN or
  386. ELSE parts.  These statements spread out over several lines,
  387. since each True BASIC statement must go on its own line.
  388.  
  389.         IF test THEN
  390.            statements...
  391.         END IF
  392.  
  393.         IF test THEN
  394.            statements...
  395.         ELSE
  396.            statements...
  397.         END IF
  398.  
  399. You can also form ``chains'' of tests, which are executed in order,
  400. by using the IF-THEN-ELSE IF statement.  This structure must always
  401. spread out over multiple lines.
  402.  
  403.         IF test1 THEN
  404.            statements...
  405.         ELSE IF test2 THEN
  406.            statements...
  407.         ELSE IF test3 THEN
  408.            statements...
  409.         ELSE
  410.            statements...
  411.         END IF
  412.  
  413. This form first checks ``test1''.  If it's true, True BASIC executes
  414. the block of statements right after test1, and then skips to the
  415. statement after the END IF.  Otherwise, True BASIC next tests
  416. ``test2'', and so forth.  Finally, if none of the tests are true,
  417. True BASIC executes the statements in the ELSE part.  (You may
  418. omit the ELSE part, if you wish.  If you do, True BASIC will
  419. simply proceed to the statement after END IF should none of
  420. the tests prove true.)
  421.  
  422.      SELECT CASE Structures
  423.  
  424. The SELECT CASE structure lets you outline a list of possible values,
  425. and check a single variable or expression against them.  It selects
  426. which block of statements to execute based on these lists of
  427. values.  Its form is:
  428.  
  429.         SELECT CASE var
  430.            CASE item, item, ...
  431.                 statements....
  432.            CASE item, item, ...
  433.                 statements...
  434.            CASE ELSE
  435.                 statements...
  436.         END SELECT
  437.  
  438. First True BASIC computes the value for the SELECT CASE expression.
  439. Then it tries to match this with the CASE items.  Each item can
  440. be a simple constant, such as ``1''.  Or it may be more complicated.
  441. The legal forms for items are:
  442.  
  443.         constant
  444.         constant TO constant
  445.         IS < constant
  446.  
  447.      WHEN ERROR Structures
  448.  
  449. Error handling is also structured.  You can intercept any error by
  450. surrounding the troublesome statements with an ``error handler''.
  451.  
  452.         WHEN ERROR IN
  453.            statements...
  454.         USE
  455.            statements...
  456.         END WHEN
  457.  
  458. The statements between USE and END WHEN are executed only if an
  459. error crops up in the first block of statements.  Otherwise they're
  460. skipped over.  The Extype function returns a numeric error code
  461. for the error that occured; the Extext$ function returns the
  462. associated error messages.
  463.  
  464. You can cause your own error conditions, with customized error
  465. messages, by using the CAUSE ERROR statement.  Its format is:
  466.  
  467.         CAUSE ERROR code,message$
  468.  
  469.  
  470.  
  471. Graphics
  472.  
  473. True BASIC's graphics are powerful and easy to use.
  474. Most versions of BASIC require you to specify your drawings in terms
  475. of ``pixels'', or the glowing dots of phosphor on the computer's screen.
  476. True BASIC lets you draw points, lines, areas, and text in terms
  477. of your own problems -- then True BASIC automatically translates
  478. these coordinates into the computer's pixels.
  479.  
  480. Since you never directly program in pixels, your programs will run
  481. on any True BASIC computer -- without change.  The same graphics
  482. program will run on the IBM PC and the Apple Macintosh.  And should
  483. you ever buy an enhanced graphics system, your programs will continue
  484. to run.  They will simply look better, thanks to the superior
  485. resolution of your new system.
  486.  
  487. The simplest plotting uses the SET WINDOW and PLOT statements.  SET
  488. WINDOW tells True BASIC what coordinates you choose to work in.
  489. (It will then translate these coordinates into pixels.)  PLOT tells
  490. True BASIC to draw a point, line, area, or text.
  491.  
  492.         set window 0, 20, -1, 1
  493.         for x = 0 to 20 step .2
  494.             plot x, Sin(x)
  495.         next x
  496.         end
  497.  
  498. Type in this program and run it.  It draws a series of points on your
  499. screen.  The SET WINDOW statement tells True BASIC that you want the
  500. screen to run from 0 to 20 along the horizontal axis, and from
  501. -1 to 1 along the vertical axis (since Sin's value always lies
  502. between -1 and 1).
  503.  
  504. Add a semicolon to the end of the PLOT statement, to leave the
  505. beam turned on during plotting.
  506.  
  507.         PLOT x, Sin(x);
  508.  
  509. Then run this new version.  Since the beam was left on, True BASIC
  510. draws a series of short line segments from each point to the next.
  511. The result is a sine wave.
  512.  
  513.      Areas
  514.  
  515. True BASIC can also plot filled ``areas'', or polygons, in a single
  516. statement.  The PLOT AREA statement takes a list of (x,y) points
  517. in your coordinates, and treats them as the vertices of a polygon.
  518. Then it draws the whole polygon, with its interior shaded.
  519.  
  520.         PLOT AREA: x1,y1; x2,y2; x3,y3; ...
  521.  
  522.     Colors
  523.  
  524. True BASIC supports all the colors on your computer.  You can specify
  525. colors by name, which makes your program portable and easy to read.
  526. Or you can use numbers, which let you get at all the colors on your
  527. computer.  On the Macintosh, True BASIC maps colors to shades of gray,
  528. since the Macintosh is a black-and-white computer.
  529.  
  530.      SET COLOR name$
  531.      SET COLOR number
  532.  
  533. You can also set the background color.
  534.  
  535.      SET BACK name$
  536.      SET BACK number
  537.  
  538. True BASIC accepts the same 10 color names on every brand of computer,
  539. though on some computers it has to fudge the meanings a little.
  540.  
  541.      ``background''     ``black''       ``white''       ``red''
  542.      ``yellow''         ``green''       ``blue''        ``brown''
  543.      ``cyan''           ``magenta''
  544.  
  545.  
  546.     The BOX Statements
  547.  
  548. The BOX statements provide extremely fast graphics on rectangular areas
  549. of the screen.  Four different statements are included:
  550.  
  551.      BOX CLEAR  x1,x2,y1,y2
  552.      BOX AREA   x1,x2,y1,y2
  553.      BOX LINES  x1,x2,y1,y2
  554.      BOX CIRCLE x1,x2,y1,y2
  555.  
  556. BOX CLEAR sets the entire rectangle to the background color.  BOX AREA
  557. sets it to the current foreground color.  BOX LINES frames the rectangle
  558. with lines drawn in the current foreground color.  BOX CIRCLE draws
  559. a circle, or an ellipse, that just fits within the indicated
  560. rectangle.
  561.  
  562. True BASIC also supports ``raster ops'' for animation.  BOX KEEP
  563. copies a portion of the screen image into a string.  BOX SHOW later
  564. redisplays this image on the screen.  Optional arguments for BOX
  565. SHOW let you perform any of 16 logical ``raster operations'' when
  566. redisplaying the image on the screen.  (Raster operations range
  567. from 0 to 15.)
  568.  
  569.      BOX KEEP x1,x2,y1,y2 IN s$
  570.      BOX SHOW s$ AT x1,y1
  571.      BOX SHOW s$ AT x1,y1 USING rasterop
  572.  
  573.  
  574.      Windows
  575.  
  576. You can open up to 10 independent ``windows'' onto your screen.  Windows
  577. can be used for both text and graphics.  True BASIC
  578. remembers each window's coordinate system, current color, and
  579. so forth.  Furthermore, each window is ``clipped'' so that graphics
  580. do not extend beyond the window's edges.  Windows also scroll independently.
  581.  
  582. To open a window, you must use an OPEN SCREEN statement, which specifies
  583. where the window should appear on the computer's screen.  These screen
  584. coordinates are given in a machine-independent form.  No matter what
  585. size screen you have, the lower left corner is always considered (0,0)
  586. and the upper right corner is (1,1).  Once you've opened a window, all
  587. subsequent screen output goes into that window.
  588.  
  589.       !  Open and use a window.
  590.       !
  591.       open #1: screen .5,1,.5,1
  592.       box lines 0,1,0,1
  593.       for i = 1 to 100
  594.           plot rnd,rnd;
  595.       next i
  596.       end
  597.  
  598. You can open up to 10 windows at once.  To switch between windows, use
  599. the WINDOW statement.  You may close windows by a CLOSE statement; all
  600. windows close automatically when your program stops.
  601.  
  602.      !  Open and use two windows.
  603.      !
  604.      open #1: screen 0,.2,0,1
  605.      open #2: screen .3,1,.3,.7
  606.      for i = 1 to 100
  607.          window #1
  608.          print i
  609.          window #2
  610.          print i;i^2
  611.      next i
  612.      close #1
  613.      close #2
  614.      end
  615.  
  616.  
  617.  
  618. Subroutines, Functions, and Libraries
  619.  
  620. Older BASICs provided only GOSUB for subroutines.  True
  621. BASIC provides full modern support for subroutines.  You may give
  622. them names, pass arguments to them, and even separately compile
  623. them.  Subroutines share their variables with the rest of the
  624. program, or may have their own ``local'' variables.
  625.  
  626. Subroutines are defined as follows:
  627.  
  628.         SUB subname
  629.            statements...
  630.         END SUB
  631.  
  632. Once you've defined a subroutine, you can use it by the CALL
  633. statement:
  634.  
  635.         CALL subname
  636.  
  637. You can defined subroutines which take ``parameters'' or dummy variables.
  638. Parameters are placeholders whose values are filled in whenever the
  639. subroutine is called.  For instance,
  640.  
  641.         SUB MySub(x,y)
  642.             PRINT x+y
  643.         END SUB
  644.  
  645. defines a small subroutine with two parameters, x and y.  This can
  646. be called from different places within your program, passing
  647. different arguments which are plugged in instead of x and y.
  648.  
  649.         CALL MySub(1,2)
  650.         CALL MySub(a*b+c,1/2)
  651.  
  652.    Local and Global Variables
  653.  
  654. True BASIC subroutines may be either ``internal'' or ``external''.  Internal
  655. subroutines come before a program's END statement.  External subroutines
  656. come after the END statement, or are kept in separate ``library'' files.
  657. There is only one difference between internal and external subroutines.
  658. Internal subroutines share all their variables with the main program.
  659. External subroutines share no variables; all their variables are
  660. local to that subroutine.
  661.  
  662.      Functions
  663.  
  664. True BASIC also lets you define functions.  As in traditional BASIC,
  665. functions can be defined on one line by a DEF statement.  You may
  666. give functions any legal variable names:
  667.  
  668.         DEF funcname = expression
  669.  
  670. You can also write functions that spill out over multiple lines.
  671. These functions begin with DEF statements and end with END DEF
  672. statements:
  673.  
  674.         DEF funcname
  675.             statements...
  676.             LET funcname = expression
  677.             statements...
  678.         END DEF
  679.  
  680. Like subroutines, functions can take parameters.  Functions can
  681. also be internal or external, and follow the same rules for
  682. local and global variables as do subroutines.  Function parameters
  683. are always pased by value in True BASIC, so functions cannot
  684. change their caller's arguments.
  685.  
  686.      Libraries
  687.  
  688. You can collect groups of useful functions and/or subroutines into
  689. ``library'' files.  These libraries act like toolboxes.  You need
  690. to define a function or subroutine only once, then place it in a
  691. library.  Then you can use this routine from any program, simply
  692. by adding a LIBRARY statement that names the library file.
  693.  
  694.         LIBRARY "filename"
  695.  
  696. The Demo Disk System does not let you use uncompiled libraries;
  697. however, the full language system allows both compiled and uncompiled
  698. library files.  You may also write functions and subroutines in assembly
  699. language and use them as True BASIC library files.
  700.  
  701.  
  702.      Built-In Functions
  703.  
  704. True BASIC comes equipped with an extensive set of functions already
  705. built into the language.  The Reference Manual describes each of
  706. these functions at length, but here is a quick synopsis.  This is
  707. only a partial list.  The True BASIC system disk also contains
  708. libraries which define all hyperbolic trigonometric functions, both
  709. in radians and degrees, and further mathematical functions.
  710.  
  711.         Mathematical Functions
  712.  
  713.         Abs(x)          Absolute values
  714.         Divide(x,y,q,r) Divide x by y, giving quotient q and remainder r
  715.         Eps(x)          Fuzziness of floating point around x
  716.         Exp(x)          The number e raised to the power x.
  717.         Int(x)          Greatest integer <= x.
  718.         Log(x)          Logarithm of x, base e.
  719.         Log2(x)         Logarithm of x, base 2.
  720.         Log10(x)        Logarithm of x, base 10.
  721.         Max(x,y)        Maximum of the two numbers.
  722.         Maxnum          Largest number your computer can handle.
  723.         Min(x,y)        Minimum of x and y.
  724.         Mod(x,Y)        x modulo y.
  725.         Remainder(x,y)  Remainder when x is divided by y.
  726.         Rnd             Random number between 0 and 1.
  727.         Round(x)        x rounded to an integer.
  728.         Round(x,n)      x rounded to n decimal digits.
  729.         Sgn(x)          Sign (-1, 0, +1) of x.
  730.         Sqr(x)          Square root of x.
  731.         Truncate(x,n)   x truncated to n decimal digits.
  732.  
  733.  
  734.         Trigonometric Functions
  735.  
  736.         Angle(x,y)      Angle between point (x,y) and origin.
  737.         Atn(x)          Arctangent of x.
  738.         Cos(x)          Cosine of x.
  739.         Deg(x)          x radians converted to degrees.
  740.         Pi              The number pi.
  741.         Rad(x)          x degrees converted to radians.
  742.         Sin(x)          Sine of x.
  743.         Tan(x)          Tangent of x.
  744.  
  745.  
  746.         String Functions
  747.  
  748.         Chr$(n)         Single-character string with ASCII code n.
  749.         Len(a$)         Length of a$.
  750.         Lcase$(a$)      Lower case version of a$.
  751.         Ltrim$(a)       Leading spaces removed from a$.
  752.         Ord(a$)         ASCII code for one-character string a$.
  753.         Pos(a$,b$,i)    Position of b$ in a$ at or after position i.
  754.         Repeat$(a$,n)   a$ repeated n times.
  755.         Rtrim$(a$)      Trailing spaces removed from a$
  756.         Str$(n)         String version of number n.
  757.         Trim$(a$)       Leading and trailing spaces removed from a$.
  758.         Ucase$(a$)      Upper case version of a$.
  759.         Using$(fmt$,a)  Formatted version of a.
  760.         Val(a$)         String a$ converted to number.
  761.  
  762.  
  763.         Date and Time Functions
  764.  
  765.         Date            Numeric date in format YYDDD.
  766.         Time            Time as seconds past midnight.
  767.         Date$           Current date.
  768.         Time$           Current time.
  769.  
  770.  
  771.  
  772.                  True BASIC Syntax Summary
  773.  
  774.  
  775. ASK Statements
  776.  
  777.     BACK var                       #n: ACCESS var$
  778.     COLOR var                      #n: FILESIZE var
  779.     CURSOR var$                    #n: MARGIN var
  780.     CURSOR x,y                     #n: NAME var$
  781.     FREE MEMORY var                #n: ORGANIZATION var$
  782.     MARGIN var                     #n: POINTER var$
  783.     MAX COLOR var                  #n: RECORD var
  784.     MAX CURSOR x,y                 #n: RECSIZE var
  785.     MODE var$                      #n: ZONEWIDTH var
  786.     SCREEN x1,x2,y1,y2
  787.     WINDOW x1,x2,y1,y2
  788.     ZONEWIDTH var
  789.  
  790. BOX AREA left, right, bottom, top
  791. BOX CIRCLE left, right, bottom, top
  792. BOX CLEAR left, right, bottom, top
  793. BOX ELLIPSE left, right, bottom, top
  794. BOX KEEP left, right, bottom, top IN var$
  795. BOX LINES left, right, bottom, top
  796. BOX SHOW var$ AT left, bottom
  797. BOX SHOW var$ AT left, bottom USING expr
  798.  
  799. CALL Subr(expr1, expr2, ...)
  800.  
  801. CAUSE ERROR expr
  802. CAUSE ERROR expr, expr$
  803.  
  804. CHAIN expr$
  805. CHAIN expr$, RETURN
  806. CHAIN expr$ WITH (arg$)
  807. CHAIN expr$ WITH (arg$), RETURN
  808.  
  809. CLEAR
  810.  
  811. CLOSE #expr
  812.  
  813. DATA item1, item2, ...
  814.  
  815. DECLARE DEF Func1, Func2, ...
  816.  
  817. DEF Func(var1, var2, ...) = expr
  818.  
  819. DEF Func(var1, var2, ...)
  820.     ....
  821.     LET Func = expr
  822.     ....
  823. END DEF
  824.  
  825. DIM array(bound, bound, ...), ...
  826. DIM array(low TO high, low TO high, ...) ...
  827.  
  828. DO             may add    WHILE condition   to either end of loop (or both)
  829.   ....                    UNTIL condition
  830.   ....
  831. LOOP
  832.  
  833. DRAW Picture
  834. DRAW Picture WITH trans * trans * ...
  835.  
  836. END
  837.  
  838. ERASE #expr
  839.  
  840. EXIT DEF
  841. EXIT DO
  842. EXIT FOR
  843. EXIT HANDLER
  844. EXIT SUB
  845.  
  846. EXTERNAL
  847.  
  848. FLOOD x,y
  849.  
  850. FOR var = first TO last STEP size
  851.     ....
  852.     ....
  853. NEXT var
  854.  
  855. GET KEY var
  856.  
  857. GET MOUSE: x, y, state
  858.  
  859. GET POINT: x, y
  860.  
  861. GOSUB line-number
  862. GOTO line-number
  863.  
  864. IF condition THEN statement1
  865. IF condition THEN statement1 ELSE statement2
  866.  
  867. IF condition THEN
  868.    ....
  869.    ....
  870. END IF
  871.  
  872. IF condition THEN
  873.    ....
  874.    ....
  875. ELSE IF condition THEN
  876.    ....
  877.    ....
  878. ELSE
  879.    ....
  880.    ....
  881. END IF
  882.  
  883. INPUT var1, var2, ...
  884. INPUT PROMPT expr$: var1, var2, ...
  885. LINE INPUT var1$, var2$, ...
  886. LINE INPUT PROMPT expr$: var1$, var2$, ...
  887.  
  888.      INPUT statements can be used with files.  Add a
  889.      channel number, such as:
  890.  
  891.              INPUT #expr: a$
  892.              LINE INPUT #expr , PROMPT expr$: var1$, var2$, ...
  893.  
  894. LET var1, var2, ... = expr
  895. LET var1$[i:j] = expr$
  896.  
  897. LIBRARY "filename", "filename", ...
  898.  
  899. MAT array = (expr)
  900. MAT array = array1 + array2
  901. MAT array = array1 - array2
  902. MAT array = array1 * array2
  903. MAT array = Inv(array1)
  904. MAT array = Trn(array1)
  905.  
  906. MAT PLOT AREA: array
  907. MAT PLOT LINES: array
  908. MAT PLOT POINTS: array
  909.  
  910.     MAT may also precede any INPUT, PRINT, READ, or WRITE statement.
  911.     If so, the statement reads/writes arrays rather than ordinary variables.
  912.  
  913. ON expr GOSUB line-number, line-number, ...
  914. ON expr GOSUB line-number, line-number, ... ELSE line-number
  915.  
  916. ON expr GOTO line-number, line-number, ...
  917. ON expr GOTO line-number, line-number, ... ELSE line-number
  918.  
  919. OPEN #expr: NAME expr$ , ACCESS accmode$
  920.                        , CREATE crtmode$
  921.                        , ORGANIZATION orgmode$
  922.                        , RECSIZE recsize
  923.  
  924.      accmode$ can be "INPUT", "OUTPUT", "OUTIN"
  925.      crtmode$ can be "NEW", "OLD", "NEWOLD"
  926.      orgmode$ can be "TEXT", "RECORD", "BYTE"
  927.  
  928. OPEN #expr: PRINTER
  929. OPEN #expr: SCREEN left, right, bottom, top
  930.  
  931. OPTION ANGLE DEGREES
  932. OPTION ANGLE RADIANS
  933. OPTION BASE constant
  934.  
  935. PAUSE expr
  936.  
  937. PICTURE Pic(var1, var2, ...)
  938.    ....
  939.    ....
  940. END PICTURE
  941.  
  942. PLAY music$
  943.  
  944. PLOT x1,y1; x2,y2; ...
  945. PLOT AREA: x1,y1; x2,y2; ...
  946. PLOT LINES: x1,y1; x2,y2; ...
  947. PLOT POINTS: x1,y1; x2,y2; ...
  948. PLOT TEXT, AT x1,y1: expr$
  949.  
  950. PRINT expr1, expr2, ...
  951. PRINT expr1; expr2; ...
  952. PRINT USING format$: expr1, expr2, ...
  953.  
  954.       +  print number with leading "+" or "-"
  955.       -  print number with leading space or "-"
  956.       $  print number with leading dollar sign
  957.  
  958.       *  print leading zeros as "*"
  959.       %  print leading zeros as "0"
  960.       #  print leading zeros as spaces
  961.  
  962.       ,  insert comma here if appropriate
  963.       .  align decimal point here
  964.       ^  exponent field
  965.       <  left justify string
  966.       >  right justify string
  967.  
  968. PROGRAM name
  969. PROGRAM name(var$)
  970.  
  971. RANDOMIZE
  972.  
  973. READ var1, var2, ...
  974. READ #expr: var1, var2, ...
  975. READ #expr, BYTES expr: var1, var2, ...
  976.  
  977. REM
  978.  
  979. RESET
  980.  
  981. RESTORE
  982.  
  983. RETURN
  984.  
  985. SELECT CASE expr                    test may be:
  986.    CASE test1, test2, ...
  987.       ....                               constant
  988.       ....                               low TO high
  989.    CASE test1, test2, ...                IS op constant
  990.       ....
  991.       ....                               'op' can be <, =, <>, etc.   
  992.    CASE ELSE
  993.       ....
  994.       ....
  995. END SELECT
  996.  
  997. SET statements
  998.  
  999.     BACK expr                 #n: MARGIN expr
  1000.     COLOR expr                #n: POINTER BEGIN
  1001.     CURSOR expr$              #n: POINTER END
  1002.     CURSOR line, column       #n: POINTER NEXT
  1003.     MARGIN expr               #n: POINTER SAME
  1004.     MODE name$                #n: RECORD expr
  1005.     WINDOW x1,x2,y1,y2        #n: RECSIZE expr
  1006.     ZONEWIDTH expr            #n: ZONEWIDTH expr
  1007.  
  1008. SOUND freq, time
  1009.  
  1010. STOP
  1011.  
  1012. SUB Subr(var1, var2, ...)
  1013.    ....
  1014.    ....
  1015. END SUB
  1016.  
  1017. UNSAVE expr$
  1018.  
  1019. WHEN ERROR IN
  1020.    ....
  1021.    ....
  1022. USE
  1023.    ....
  1024.    ....
  1025. END WHEN
  1026.  
  1027. WINDOW #expr
  1028.  
  1029. WRITE #expr: expr1, expr2, ...
  1030.